require(['./config'],()=>{
	require(['template','header','footer'],(template)=>{
		class List{
			constructor(){
			this.getList()	
			this.getLbt()
			this.Swiper()
			}
			getList(){
				const id=location.search.slice(4)
				$.get(`http://www.xiongmaoyouxuan.com/api/tab/${id}`,{start:0,sort:1},resp=>{
					if(resp.code===200){
						const {list}=resp.data.items
						$('#good').html(template('goodTemplate',{list}))
					}
				})
			}  
			getLbt(){
				$.get('http://www.xiongmaoyouxuan.com/api/tab/1',resp=>{
					if(resp.code===200){
						const {banners}=resp.data
						$('#lbt').html(template('lbtTemplate',{banners}))
					}
				})
			}
			Swiper(){
				var mySwiper = new Swiper('.swiper-container', {
				observer:true,//修改swiper自己或子元素时，自动初始化swiper 
				observeParents:true,//修改swiper的父元素时，自动初始化swiper 
					direction: 'horizontal', 
					loop: true,
					autoplay: {
						disableOnInteraction: false,
					}, //自动轮播
					speed:4000,
					navigation: {
						nextEl: '.swiper-button-next',
						prevEl: '.swiper-button-prev',
					}
				}); 
				// Swiper.el.onmouseover = function(){ //鼠标放上暂停轮播
				// 	mySwiper.autoplay.stop();
				// }
				// mySwiper.el.onmouseleave = function(){
				// 	mySwiper.autoplay.start();
				// }
			}
		}
		new List()
	})
})